<cfcomponent 
	displayname="InterestForm" 
	output="false" 
	hint="Interest form bean for cffringe.org">

	<cffunction name="init" access="public" output="false" returntype="InterestForm">
		<cfargument name="firstName" type="string" required="false" default="" />
		<cfargument name="lastName" type="string" required="false" default="" />
		<cfargument name="email" type="string" required="false" default="" />
		<cfargument name="company" type="string" required="false" default="" />
		<cfargument name="levelOfInterest" type="numeric" required="false" default="0" />
		<cfargument name="comments" type="string" required="false" default="" />
		<cfargument name="dtReceived" type="date" required="false" default="#Now()#" />
		
		<cfscript>
			setFirstName(arguments.firstName);
			setLastName(arguments.lastName);
			setEmail(arguments.email);
			setCompany(arguments.company);
			setLevelOfInterest(arguments.levelOfInterest);
			setComments(arguments.comments);
			setDtReceived(arguments.dtReceived);
			
			return this;
		</cfscript>
	</cffunction>
	
	<cffunction name="setFirstName" access="public" output="false" returntype="void">
		<cfargument name="firstName" type="string" required="true" />
		<cfset variables.firstName = arguments.firstName />
	</cffunction>
	<cffunction name="getFirstName" access="public" output="false" returntype="string">
		<cfreturn variables.firstName />
	</cffunction>

	<cffunction name="setLastName" access="public" output="false" returntype="void">
		<cfargument name="lastName" type="string" required="true" />
		<cfset variables.lastName = arguments.lastName />
	</cffunction>
	<cffunction name="getLastName" access="public" output="false" returntype="string">
		<cfreturn variables.lastName />
	</cffunction>

	<cffunction name="setEmail" access="public" output="false" returntype="void">
		<cfargument name="email" type="string" required="true" />
		<cfset variables.email = arguments.email />
	</cffunction>
	<cffunction name="getEmail" access="public" output="false" returntype="string">
		<cfreturn variables.email />
	</cffunction>

	<cffunction name="setCompany" access="public" output="false" returntype="void">
		<cfargument name="company" type="string" required="true" />
		<cfset variables.company = arguments.company />
	</cffunction>
	<cffunction name="getCompany" access="public" output="false" returntype="string">
		<cfreturn variables.company />
	</cffunction>

	<cffunction name="setLevelOfInterest" access="public" output="false" returntype="void">
		<cfargument name="levelOfInterest" type="numeric" required="true" />
		<cfset variables.levelOfInterest = arguments.levelOfInterest />
	</cffunction>
	<cffunction name="getLevelOfInterest" access="public" output="false" returntype="numeric">
		<cfreturn variables.levelOfInterest />
	</cffunction>

	<cffunction name="setComments" access="public" output="false" returntype="void">
		<cfargument name="comments" type="string" required="true" />
		<cfset variables.comments = arguments.comments />
	</cffunction>
	<cffunction name="getComments" access="public" output="false" returntype="string">
		<cfreturn variables.comments />
	</cffunction>

	<cffunction name="setDtReceived" access="public" output="false" returntype="void">
		<cfargument name="dtReceived" type="date" required="true" />
		<cfset variables.dtReceived = arguments.dtReceived />
	</cffunction>
	<cffunction name="getDtReceived" access="public" output="false" returntype="date">
		<cfreturn variables.dtReceived />
	</cffunction>
	
	<cffunction name="validate" access="public" output="false" returntype="array">
		<cfscript>
			var errors = ArrayNew(1);
			var error = 0;
			
			if (getFirstName() eq "") {
				error = StructNew();
				error.formField = "firstName";
				error.message = "Please provide your first name";
				ArrayAppend(errors, error);
			}
			
			if (getLastName() eq "") {
				error = StructNew();
				error.formField = "lastName";
				error.message = "Please provide your last name";
				ArrayAppend(errors, error);
			}
			
			if (getEmail() eq "" or not IsValid("email", getEmail())) {
				error = StructNew();
				error.formField = "email";
				error.message = "Please provide a valid email address";
				ArrayAppend(errors, error);
			}
			
			return errors;
		</cfscript>
	</cffunction>
	
	<cffunction name="dump" access="public" output="true" returntype="void">
		<cfargument name="abort" type="boolean" required="false" default="false" />
		<cfdump var="#variables#" />
		<cfif arguments.abort>
			<cfabort />
		</cfif>
	</cffunction>

</cfcomponent>